import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

import { Api } from '../providers/api';

@Injectable()
export class WeChatApi {

    constructor(public http: Http, public api: Api) {

    }
    //绑定决赛组
    splitgroup(id)
    {
      
              return this.api.get('total/splitFinals/'+id)
            .map(res => res.json());
    }






    //
    postData(result)
    {
        return this.api.post('time/postdata/', result)
            .map(resp => resp.json())


    }





    //

    //
    
     updatescore(score,company) {
        return this.api.get('time/updatescore/'+score+'/'+company)
            .map(res => res.json());
    }
    
     updateopenid(openid,company) {
        return this.api.get('time/updateopenid/'+openid+'/'+company)
            .map(res => res.json());
    }
    
     time(group,tag) {
        return this.api.get('time/time/'+group+'/'+tag)
            .map(res => res.json());
    }
    
      endtime(group,tag) {
        return this.api.get('time/endtime/'+group+'/'+tag)
            .map(res => res.json());
    }




    //

    getsignature(url) {
        return this.api.get('webchat/wechatsign/123')
            .map(res => res.json());
    }
    //GetSign
      GetSign() {
        return this.api.get('webchat/GetSign',1)
            .map(res => res.json());
    }
      getscore(openid) {
        return this.api.get('webchat/getScore/'+openid)
            .map(res => res.json());
    }
      insertscore(score,openid,img,tag) {
        return this.api.get('webchat/openidinsert/'+openid+'/'+img+'/'+score+'/'+tag)
            .map(res => res.json());
    }
    score(id:String)
    {
       
             return this.api.get('webchat/scorecode/' +id)
            .map(res => res.json());

    }
    getwxopenid(code: String) {
        return this.api.get('webchat/getwxopenid/' + code)
            .map(res => res.json());
    }
    //GetWChatToken 调用c# 后台
    GetWChatToken(code: String) {
        return this.api.get('webchat/GetWChatToken?code=' + code)
            .map(res => res.json());
    }
     getpersonM(id: String) {
        return this.api.get('webchat/person/' + id)
            .map(res => res.json());
    }

    getimage(access_token: String, media_id: String) {
        return this.api.get('webchat/getimage/' + access_token + '/' + media_id)
            .map(res => res.json());
    }
    //c#版本
     GetPictureDownloadUrl(access_token: String, media_id: String) {
        return this.api.get('webchat/GetPictureDownloadUrl?access_token=' + access_token + '&mediaId=' + media_id)
            .map(res => res.json());
    }

    getmapjson(location: String, longitude: String) {
        return this.api.mapjson("http://apis.map.qq.com/ws/geocoder/v1/?location=" + location + "," + longitude + "&coord_type=5&key=你自己的腾讯开放平台的开发者秘钥&output=jsonp&callback=calllocation")
            .map(res => res.json());
    }
    getcode() {

        return this.api.get('webchat/getcode')
            .map(res => res.json());
    }
    
    headimage(openid:any,access_token:any) {

        return this.api.get('webchat/headimage/'+openid+'/'+access_token)
            .map(res => res.json());
    }
      wechattoken() {

        return this.api.get('webchat/wechattoken')
            .map(res => res.json());
    }
     sweepcodeScore(openid:any,path:any,score:any,tag) {

        return this.api.get('webchat/score/'+openid+'/'+path+'/'+score+'/'+tag )
            .map(res => res.json());
    }
    person(id:any)
    {
        return this.api.get('person/'+id )
            .map(res => res.json());

    }


}
